
<%@page import="com.netcracker.entity.Genre"%>
<%@page import="com.netcracker.entity.Author"%>
<%@page import="com.netcracker.entity.Book"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    Book currentBook = (Book) request.getAttribute("book");
    String path = request.getContextPath();
%>
<article id="book">
    <header class="elem_bground">
        <h1 id="title">
            <%=currentBook.getName()%>
        </h1>
        <h2 id="author">
            <%
                for (Author author : currentBook.getAuthors()) {
                    out.print("<a href=\"" + path + "?action=findBook&type=byAuthor&author=" + author.getFullName() + "\">" + author.getFullName() + "</a> \n");
                }
            %>
        </h2>
    </header>
    <figure id="cover" class="elem_bground">
        <img src="<%=path + "/ImageServlet?id=" + currentBook.getId()%>" alt="<%=currentBook.getName()%>" />
    </figure>
    <section id="info" class="elem_bground">
        <ul>
            <li>Жанр: 
                <%
                    for (Genre genre : currentBook.getGenres()) {
                        out.print("<a href=\"" + path + "?action=findBook&type=byGenre&genreId=" + genre.getId() + "\"> " + genre.getName() + "</a> \n");
                    }

                %>
            </li>
            <li> Год: <%=currentBook.getYear().toString()%></li>
            <li> Издательство: <%=currentBook.getPublisher().getName()%></li>
            <li> Номер издания: <%=currentBook.getEdition()%></li>
            <li> Страниц: <%=currentBook.getNumberOfPages()%></li>
            <li> Язык: <%=currentBook.getLanguage()%></li>
        </ul>
    </section>
    <section id="description" class="elem_bground">
        <p>
            <%=currentBook.getDescription()%>
        </p>
    </section>
    <footer>
        <section id="added">
            <p><%= currentBook.getPublicDate()%></br>
                <%= currentBook.getUser().getLogin()%></p>
        </section>
        <a  href="<%= path + "/DownloadServlet?bookID=" + currentBook.getId()%>" class="button">СКАЧАТЬ </a>
    </footer>
</article><!--book-->
